package it.carlom.stickyheader.example.fragment;


import it.carlom.stickyheader.ResourceTable;
import it.carlom.stickyheader.example.Utils;
import it.carlom.stickyheader.example.adapter.TextAdapter;
import it.carlom.stikkyheader.core.StikkyHeaderBuilder;
import it.carlom.stikkyheader.core.utils.LogUtil;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.LayoutScatter;
import ohos.agp.components.ListContainer;

public class SimpleStikkyFragment extends BaseFraction {


    public SimpleStikkyFragment() {
    }

    @Override
    protected Component onComponentAttached(LayoutScatter scatter, ComponentContainer container, Intent intent) {
        return scatter.parse(ResourceTable.Layout_fragment_simplelistview, container, false);
    }

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        ListContainer listView = (ListContainer) getComponent().findComponentById(ResourceTable.Id_listview);
        Component header = getComponent().findComponentById(ResourceTable.Id_header);

        listView.setItemProvider(new TextAdapter(getFractionAbility(), Utils.getData()));
        StikkyHeaderBuilder.stickTo(listView)
                .setHeader(header)
                .minHeightHeader(250)
                .build();
        listView.setItemClickedListener((listContainer, component, i, l) -> LogUtil.loge("我的高度 " + component.getHeight()));

    }

}
